#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;

int main()
{
	int n;
	int total = 0;
	int empty = 0;
	while (cin >> n && n)
	{
		empty = n;
		total = 0;
		while (empty >= 3)
		{
			total += empty / 3;
			empty = empty / 3 + empty % 3;
			if (empty == 2)
				total++;
		}
		cout << total << endl;
	}
	return 0;
}